var e = require;
var t = module;
var o = exports;
var ii, nn = this && this.__extends || (ii = function (t, e) {
    return (ii = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        ii(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }
),
    rr = this && this.__awaiter ||
        function (t, e, o, i) {
            return new (o || (o = Promise))(function (n, a) {
                function r(t) {
                    try {
                        l(i.next(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function s(t) {
                    try {
                        l(i.
                            throw(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function l(t) {
                    var e;
                    t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
                        t(e)
                    })).then(r, s)
                }
                l((i = i.apply(t, e || [])).next())
            })
        };
var oo = (this && this.__decorate) ||
    function (e, t, a, n) {
        var i,
            o = arguments.length,
            s = o < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, a)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);
        else
            for (var r = e.length - 1; r >= 0; r--)
                (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
        return o > 3 && s && Object.defineProperty(t, a, s), s;
    }; Object.defineProperty(o, "__esModule", { value: !0 }), (o.DailogButton = o.DialogPanel = void 0);
var a = e("ASCAd"),
    n = (function () {
        function e() { }
        return (
            (e.getNetworkType = function (e) {
                cc.sys.platform == cc.sys.VIVO_GAME || cc.sys.platform == cc.sys.OPPO_GAME
                    ? qg.getNetworkType({
                        success: function (t) {
                            cc.sys.platform === cc.sys.VIVO_GAME
                                ? (console.log("vivo network getNetworkType type:", t.type),
                                    "none" != t.type && "2g" != t.type && "3g" != t.type
                                        ? e && e(!0)
                                        : (console.log("vivo 无网络连接"), e && e(!1)))
                                : cc.sys.platform === cc.sys.OPPO_GAME
                                    ? (console.log("oppo network getNetworkType type:", t.networkType),
                                        "none" != t.networkType && "2g" != t.networkType && "3g" != t.networkType
                                            ? e && e(!0)
                                            : e && e(!1))
                                    : cc.sys.platform === cc.sys.HUAWEI_GAME &&
                                    (console.log("getNetworkType success networkType   " + t.networkType),
                                        "none" != t.networkType && "2g" != t.networkType && "3g" != t.networkType
                                            ? e && e(!0)
                                            : e && e(!1));
                        },
                        fail: function (t) {
                            e && e(!1), console.log("network getNetworkType   ", t.errMsg);
                        },
                        complete: function () { }
                    })
                    : cc.sys.platform == cc.sys.HUAWEI_GAME
                        ? hbs.getNetworkType({
                            success: function (t) {
                                console.log("getNetworkType success networkType   " + t.networkType),
                                    "none" != t.networkType && "2g" != t.networkType && "3g" != t.networkType
                                        ? e && e(!0)
                                        : e && e(!1);
                            },
                            fail: function (t) {
                                e && e(!1), console.log("network getNetworkType   ", t.errMsg);
                            },
                            complete: function () { }
                        })
                        : e && e(!0);
            }),
            (e.subscribeNetworkStatus = function (e) {
                cc.sys.platform === cc.sys.VIVO_GAME
                    ? qg.subscribeNetworkStatus({
                        callback: function (t) {
                            console.log("vivo network status ,type:", t.type),
                                "none" != t.type && "2g" != t.type && "3g" != t.type ? e && e(!0) : e && e(!1);
                        }
                    })
                    : cc.sys.platform === cc.sys.OPPO_GAME
                        ? qg.onNetworkStatusChange(function (t) {
                            console.log(
                                "oppo network status ,isConnected:",
                                t.isConnected,
                                ",networkType:",
                                t.netWorkType
                            ),
                                t.isConnected && "none" != t.networkType && "2g" != t.networkType && "3g" != t.networkType
                                    ? e && e(!0)
                                    : e && e(!1);
                        })
                        : cc.sys.platform === cc.sys.HUAWEI_GAME
                            ? hbs.onNetworkStatusChange(function (t) {
                                console.log(
                                    "onNetworkStatusChange isConnected = " +
                                    t.isConnected +
                                    ", networkType = " +
                                    t.networkType
                                ),
                                    t.isConnected && "none" != t.networkType && "2g" != t.networkType && "3g" != t.networkType
                                        ? e && e(!0)
                                        : e && e(!1);
                            })
                            : e && e(!0);
            }),
            (e.showDialog = function (e, t, o, a, n) {
                if ((void 0 === a && (a = null), void 0 === n && (n = null), cc.sys.platform === cc.sys.VIVO_GAME)) {
                    var s = new i();
                    (s.title = e), (s.message = t);
                    var l = new r();
                    (l.text = "确定"),
                        s.buttons.push(l),
                        (s.success = function (e) {
                            console.log("dialog 成功回调：", e.index),
                                0 == e.index ? o() : 1 == e.index ? a && a() : 2 == e.index && n && n();
                        }),
                        (s.cancel = function () {
                            console.log("dialog 取消回调：");
                        }),
                        (s.fail = function (e, t) {
                            console.log("dialog 失败回调：", e, ",====code", t);
                        }),
                        cc.sys.platform === cc.sys.VIVO_GAME && qg.showDialog(s);
                } else
                    cc.sys.platform == cc.sys.OPPO_GAME
                        ? qg.showModal({
                            title: e,
                            content: t,
                            success: function (e) {
                                e.confirm
                                    ? (console.log("用户点击确定"), o && o())
                                    : e.cancel && (console.log("用户点击取消"), a && a());
                            }
                        })
                        : cc.sys.platform == cc.sys.HUAWEI_GAME
                            ? qg.showModal({
                                title: e,
                                content: t,
                                success: function (e) {
                                    e ? (console.log("用户点击确定"), o && o()) : (console.log("用户点击取消"), a && a());
                                }
                            })
                            : console.log("other platform show dialog");
            }),
            (e.showToast = function (e, t) {
                cc.sys.platform == cc.sys.VIVO_GAME
                    ? qg.showToast({ message: e, duration: t })
                    : cc.sys.platform == cc.sys.OPPO_GAME && qg.showToast({ title: e, icon: "success", duration: t });
            }),
            (e.vibrateShort = function () {
                a.default.getInstance().phoneVibrate("short");
            }),
            (e.vibrateLong = function () {
                a.default.getInstance().phoneVibrate("short");
            }),
            (e.onApplication = function (e) {
                cc.sys.platform === cc.sys.VIVO_GAME &&
                    (qg.onShow(function () {
                        console.log("vivo game enter foreground"), e && e(!0);
                    }),
                        qg.onHide(function () {
                            console.log("vivo game enter background"), e && e(!1);
                        }));
            }),
            (e.exitApplication = function () {
                cc.sys.platform === cc.sys.VIVO_GAME
                    ? qg.exitApplication()
                    : cc.sys.platform === cc.sys.OPPO_GAME
                        ? qg.exitApplication({})
                        : cc.sys.platform === cc.sys.HUAWEI_GAME && hbs.exitApplication({});
            }),
            e
        );
    })();
o.default = n;
var i = function () {
    (this.title = "title"), (this.message = "message"), (this.buttons = []);
};
o.DialogPanel = i;
var r = function () {
    (this.text = "按钮"), (this.color = "#33dd44");
};
o.DailogButton = r;
